/**
 * @date 11:40:24 AM
 * EducationHomeWorkStudentDaoImpl.java
 * Administrator
 * TODO
 */
package com.qs.education.bean.dao.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.qs.education.bean.dao.IEducationHomeWorkStudentDao;
import com.qs.education.bean.entity.EducationHomeWork;
import com.qs.education.bean.entity.EducationHomeWorkStudent;
import com.qs.education.bean.entity.EducationStudent;
/**
 * @class EducationHomeWorkStudentDaoImpl	
 * @author Warren
 * @description
 * @date Nov 20, 2018 
 */
@Repository
public class EducationHomeWorkStudentDaoImpl extends BaseDaoImpl<EducationHomeWorkStudent> implements IEducationHomeWorkStudentDao{

	/**
	 * @author Warren
	 * @param educationStudent
	 * @return ResponseListBean<EducationHomeWorkStudent>
	 * @description 根据学生id查询学生的作业
	 * @date Nov 20, 2018
	 */
	@Override
	public List<EducationHomeWorkStudent> getListByStudentId(EducationStudent educationStudent) {
		String jql = "from EducationHomeWorkStudent ehs where ehs.student = :student";
		Map<String, Object> params = new HashMap<>();
		params.put("student", educationStudent);
		List<EducationHomeWorkStudent> result = query(jql, EducationHomeWorkStudent.class, params);
		if(null != result && !result.isEmpty()){
			return result;
		}
		return null;
	}

	/**
	 * @author Warren
	 * @param educationStudent 学生实体
	 * @param educationHomeWork 作业实体
	 * @return EducationHomeWorkStudent
	 * @description 
	 * @date Nov 22, 2018
	 */
	@Override
	public EducationHomeWorkStudent findEducationHomeWorkStudentByStudentAndHomeWork(EducationStudent educationStudent,
			EducationHomeWork educationHomeWork) {
		String jql = "from EducationHomeWorkStudent ehs where ehs.student = :student and ehs.homework = :homework";
		Map<String, Object> params = new HashMap<>();
		params.put("student", educationStudent);
		params.put("homework", educationHomeWork);
		List<EducationHomeWorkStudent> result = query(jql, EducationHomeWorkStudent.class, params);
		if(null != result && !result.isEmpty()){
			return result.get(0);
		}
		return null;
	}

	/**
	 * @author Warren
	 * @param educationHomeWork
	 * @return List<EducationHomeWorkStudent>
	 * @description 根据作业查询学生
	 * @date Nov 23, 2018
	 */
	@Override
	public List<EducationHomeWorkStudent> findEducationHomeWorkStudentByHomeWork(EducationHomeWork educationHomeWork) {
		String jql = "from EducationHomeWorkStudent ehs where ehs.homework = :homework";
		Map<String, Object> params = new HashMap<>();
		params.put("homework", educationHomeWork);
		List<EducationHomeWorkStudent> result = query(jql, EducationHomeWorkStudent.class, params);
		if(null != result && !result.isEmpty()){
			return result;
		}
		return null;
	}

}
